APA in-text citations to scrapbox tag
You can copy and paste this code into your Scrapbox page (but I cannot promise it will work as you want...).
Here is the prototype ver 1.2
Modified 2020/6/20—Now reformat (but see Author, XXXX) or (but for **** see Author, XXXX) Modified 2020/6/26—Now it adds parenthesis around the publication year. Modified 2020/6/28—Bug fixed: I mixed up // and # to comment out... code:script.js
scrapbox.PopupMenu.addButton({
title: 'APA2Tags',
onClick: text => text.split(';').map(function(line) {
return line.replace(/e\.g\.(,|)\s/, "") //delete "e.g.,"
.replace(/i\.e\.(,|)\s/, "") //delete "i.e.,"
.replace(/et al./, "_et_al") //reformat et al.
.replace(/(but\s|\,\s|\s)for.*?(see|\))/, "") //intended to delete "for a discussion see" or similar strings
.replace(/(but\s|)see/,'') //intended to delete "see"
.replace(/,/g, '_')
.replace(/&|\sand\s/g, '_&_')
.replace(/\(|\)|\.|\?/g, "") // delete unnecessary punctuations
.replace(/ /g, "")
.replace (/^/,'#')
.replace(/__/, '_')
.replace(/\d{4}/gm, "($&)") //adding parenthesis around the publication year
}).join(' ')
})
Examples
One paper
(Nation, 1990)
One paper with comments
(e.g., Suzuki & Kormos, 2019, for prosody)
(see McKiernan et al., 2016)
Multiple citations, using ; as a break
(Nagy & Scott, 2000; Nation, 1990; Read, 2004)
(e.g. Jenkins 1970; Randall 1980; Söderman 1993)